package com.jt.www.aop;

import com.jt.www.model.param.BaseParam;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class ParamCheckHandler {

    public static final Logger log = LoggerFactory.getLogger(ParamCheckHandler.class);

    @Before("execution(public * com.jt.www.controller..*.*(..)) || " +
            "execution(public * com.jt.www.biz.order_pc.controller..*.*(..)) ||" +
            "execution(public * com.jt.www.biz.order_wxb.controller..*.*(..)) ||" +
            "execution(public * com.jt.www.biz.user_pc.controller..*.*(..)) ||" +
            "execution(public * com.jt.www.biz.user_wxb.controller..*.*(..)) ||" +
            "execution(public * com.jt.www.admin.order_pc.controller..*.*(..)) ||" +
            "execution(public * com.jt.www.admin.order_wxb.controller..*.*(..)) ||" +
            "execution(public * com.jt.www.admin.user.controller..*.*(..)) ||" +
            "execution(public * com.jt.www.survey.controller..*.*(..)) ")
    public void before2(JoinPoint joinPoint) {
        //请求的参数
        Object[] args = joinPoint.getArgs();
        if (args == null || args.length == 0) {
            return;
        }
        for (Object object : args) {
            if (object == null) {
                continue;
            }
            if (object instanceof BaseParam) {
                BaseParam baseParam = (BaseParam) object;
                baseParam.checkParam();
            }
        }
    }
}
